package com.demo.job.anno.controller;

import com.demo.job.anno.utils.IJobHandler;
import com.demo.job.anno.utils.JobSpringExecutor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author peter
 * @date 2022/4/11 0:59
 */
@RestController
public class IndexController {

    @GetMapping("test")
    public String test() {
        try {
            // 无参无返回值执行
            IJobHandler emptyMethod = JobSpringExecutor.loadJobHandler("emptyMethod");
            emptyMethod.execute();

            // 有参无返回值执行
            IJobHandler paramMethod = JobSpringExecutor.loadJobHandler("paramMethod");
            paramMethod.execute("peter", 18);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "ok";
    }
}
